package com.pc.tas.util;

public class Utils {
	public static long getUniqueLong(long type,long resourceId,long actorId) throws Exception  {
		if(type<0 || type > 15) {
			throw new Exception("type: " + type + " is too big!");			
		}
		
		if(resourceId<0 || resourceId > 268435455) {
			throw new Exception("resource: " + resourceId + " is too big!");
		}
		
		return (type<<60) + (resourceId <<32) + (actorId);
	}
	
	public static long getUniqueLong(long type,long resourceId,String actorId) throws Exception {		
		return getUniqueLong(type,resourceId,IPUtil.ip2Long(actorId));
	}
	
    public static String getProductUrl(String id,String defaultUri) {
        if(id==null){
            return "";
        }
        String url = defaultUri.replaceAll("\\{id\\}", id); 
        return url;
    }
}
